package com.kwedding.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.kwedding.dto.web.RequestWebAddImages;
import com.kwedding.dto.web.RequestWebAddStyle;
import com.kwedding.dto.web.RequestWebBrandImageByType;
import com.kwedding.dto.web.RequestWebGetBrandImages;
import com.kwedding.dto.web.RequestWebUpDownImage;
import com.kwedding.dto.web.RequestWebUpdateBrandImages;
import com.kwedding.dto.web.ResponseWebBrandImages;
import com.kwedding.service.web.WebImagesService;
import com.kwedding.util.BackJson;
import com.kwedding.util.JsonBackBase;
import com.kwedding.util.LoggerParent;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@Controller
@RequestMapping("rest/web/image")
@Api(tags = "图片管理")
public class WebImageController extends LoggerParent {

	@Autowired
	private WebImagesService webImagesService;

	@ApiOperation("添加图片")
	@ResponseBody
	@RequestMapping(value = "insertImages", method = { RequestMethod.POST })
	private JsonBackBase insertImages(@RequestBody RequestWebAddImages webAddImages) {
		webImagesService.insertImages(webAddImages);
		return BackJson.success();
	}

	@ApiOperation(" 获取品牌图片")
	@ResponseBody
	@RequestMapping(value = "getImageByBrandId", method = { RequestMethod.POST })
	private JsonBackBase<List<ResponseWebBrandImages>> getImageByBrandId(
			@RequestBody RequestWebGetBrandImages getBrandImages) {
		return BackJson.successObj(webImagesService.getImageByBrandId(getBrandImages));
	}

	@ApiOperation(" 根据类型获取品牌图片")
	@ResponseBody
	@RequestMapping(value = "getImageByBrandIdAndType", method = { RequestMethod.POST })
	private JsonBackBase<List<ResponseWebBrandImages>> getImageByBrandIdAndType(
			@RequestBody RequestWebBrandImageByType brandImageByType) {
		return BackJson.successObj(webImagesService.getBrandImageByType(brandImageByType));
	}

	@ApiOperation("修改品牌图片")
	@ResponseBody
	@RequestMapping(value = "updateBrandImages", method = { RequestMethod.POST })
	private JsonBackBase updateBrandImages(@RequestBody RequestWebUpdateBrandImages updateBrandImages) {
		webImagesService.updateBrandImages(updateBrandImages);
		return BackJson.success();
	}

	@ApiOperation("修改品牌图片状态")
	@ResponseBody
	@RequestMapping(value = "upDownImage", method = { RequestMethod.POST })
	private JsonBackBase upDownImage(@RequestBody RequestWebUpDownImage upDownImage) {
		webImagesService.upDownImage(upDownImage);
		return BackJson.success();
	}

}
